package com.douqu.game.core.entity.battle;

import com.douqu.game.core.config.common.GoodsData;
import com.douqu.game.core.entity.EntityObject;
import com.douqu.game.core.protobuf.SGCommonProto;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-03-23 21:16
 */
public class BattleResultParam extends EntityObject {

    private List<GoodsData> rewardList;

    public BattleResultParam()
    {
        rewardList = new ArrayList<>();
    }

    public void addReward(GoodsData goodsData)
    {
        rewardList.add(goodsData);
    }

    public void addReward(GoodsData[] goodsData)
    {
        if(goodsData == null)
            return;

        for(GoodsData data : goodsData){
            addReward(data);
        }
    }

    public List<SGCommonProto.GoodsObject> parseList()
    {
        List<SGCommonProto.GoodsObject> list = new ArrayList<>();
        for(GoodsData goodsData : rewardList)
        {
            list.add(goodsData.parse().build());
        }

        return list;
    }

    public List<GoodsData> getRewardList() {
        return rewardList;
    }

    public GoodsData[] getRewardArray() {
        if(rewardList == null){
            return new GoodsData[0];
        }
        GoodsData[] datas = new GoodsData[rewardList.size()];
        for(int i = 0; i < rewardList.size(); i++){
            datas[i] = rewardList.get(i);
        }
        return datas;
    }

    public void setRewardList(List<GoodsData> rewardList) {
        this.rewardList = rewardList;
    }
}
